define(function(require, exports, module) {
  	var $  = jQuery = require('jquery');
    window.jQuery = window.$ = $;
    var public_panel = $('#public_panel');
    //引入js
  	require.async('layouts/bootstrap/js/bootstrap.min');
  	require.async('layouts/js/modernizr.min');
  	require.async('layouts/js/pace.min');
  	require.async('layouts/js/jquery.scrollTo.min');
  	require.async('layouts/js/jquery.nicescroll');
    require.async('layouts/js/notify.min');
    require.async('layouts/js/notify-metro');
    require.async('layouts/sweetAlert/sweet-alert.min');

  	require.async('layouts/js/wow.min',function (){
  		var wow = new WOW(
		    {
		        boxClass: 'wow', // animated element css class (default is wow)
		        animateClass: 'animated', // animation css class (default is animated)
		        offset: 50, // distance to the element when triggering the animation (default is 0)
		        mobile: false        // trigger animations on mobile devices (true is default)
		    }
		);
		wow.init();
  	});

    require('js/admin/admin/sidebar_init');
    $.SideBar.init();


//------------------------公共格式错误 start---------------------------------
$('input').focus(function (){
    $(this).closest('.form-group').removeClass('has-error');
})

$('select').click(function (){
    $(this).closest('.form-group').removeClass('has-error');  
})

//------------------------公共格式错误 end---------------------------------

//引入相应系统模块公共JS
if(window.location.pathname.indexOf('cu')>0){
    require.async('js/admin/admin/cu/public');    
}

//头部导航左侧导航显示隐藏
$('#left_nav li').click(function (){
    var mod = $(this).attr('mod'),
        left_model = $('.list-unstyled');
    $(this).closest('ul').find('li').removeClass('active');
    $(this).addClass('active');
    left_model.children('li').hide();
    left_model.children('li').each(function (){
        if($(this).attr('mod')==mod){
            $(this).show(500).find('li').show();
        }
    })
})

//密码重置
$('#pwd_reset').click(function (){
    init_public_panel();
    public_panel.find('.modal-header h4').html('密码重置');
    $.ajax({
        url: '/admin/userinfo/reset/password',
        type: 'get',
        dataType: 'html',
        success:function (res){
            public_panel.find('#public_form').html(res);
        }
    })
    public_panel.modal('show');
})

function init_public_panel(){
    public_panel.find('.modal-header h4').html('');
    public_panel.find('form').html('');
}


$.ajaxSetup({
    headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
});
if(document.documentElement.clientWidth<600){
    $('.logo').hide();
}else{
    $('.logo').show();
}

//动态加载模块JS
if(control_js==''){
    var urlArr = window.location.pathname.substr(1).split('/');
    if(!isNaN(urlArr[urlArr.length-1])){
        var url = '';
        urlArr.pop();
        for(var u in urlArr){
            url += '/'+urlArr[u];
        }
        require.async('js/admin'+url);
    }else{
        require.async('js/admin'+window.location.pathname);
    }
}else{
    require.async('js/admin'+control_js);
}

});